package AcWing.每日一题2025;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * @author ZhuYi
 * @create 2025/3/4 18:01
 * 模拟
 */
public class 农夫约翰的奶酪块_6122 {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] sp = br.readLine().split(" ");
        int n = Integer.parseInt(sp[0]);
        int q = Integer.parseInt(sp[1]);
        int[][] a = new int[n][n];
        int[][] b = new int[n][n];
        int[][] c = new int[n][n];
        int res = 0;
        while (q != 0) {
            String[] sp2 = br.readLine().split(" ");
            int x = Integer.parseInt(sp2[0]);
            int y = Integer.parseInt(sp2[1]);
            int z = Integer.parseInt(sp2[2]);

            if (++a[x][y] == n) {
                res++;
            }
            if (++b[y][z] == n) {
                res++;
            }
            if (++c[x][z] == n) {
                res++;
            }
            System.out.println(res);
            q--;
        }
    }
}
